package 题目集.链表.环;

import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

//每次从下一个开始
public class 约瑟夫环 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        Queue<Integer> queue=new ArrayDeque<>();
        int n = sc.nextInt();
        int m = sc.nextInt();
        for (int i = 0; i < n; i++) {
            queue.add(i+1);
        }
        for (int i = 0; i < m; i++) {
            int ai = sc.nextInt();
            ai%=queue.size();
            for (int j = 0; j < ai; j++) {
                queue.add(queue.poll());
            }
            System.out.print(queue.poll()+" ");
        }
    }
}
